<template>
	<div>
		<el-form ref="form" :model="form" label-width="80px">

			<el-form-item label="姓名">
				<el-input v-model="form.name"></el-input>
			</el-form-item>


			<el-form-item label="性别">
				<el-input v-model="form.gender"></el-input>
			</el-form-item>

			<el-form-item label="年龄">
				<el-input v-model="form.age"></el-input>
			</el-form-item>
			
			<el-form-item label="类别">
				<el-select v-model="form.type" name="select-active-1" type="lable">
					<el-option value="评估医生">评估医生</el-option>
					<el-option value="责任医生">责任医生</el-option>
					<el-option value="健康管家">健康管家</el-option>
					<el-option value="护工">护工</el-option>
				</el-select>
			</el-form-item>
			
			<el-form-item label="身份证号">
				<el-input v-model="form.idNum"></el-input>
			</el-form-item>
			
			<el-form-item label="职称">
				<el-input v-model="form.jobTitle"></el-input>
			</el-form-item>
			
			<el-form-item label="职务">
				<el-input v-model="form.position"></el-input>
			</el-form-item>
			
			<el-form-item label="简介">
				<el-input v-model="form.introduction"></el-input>
			</el-form-item>
			
			<el-form-item label="电话">
				<el-input v-model="form.telephone"></el-input>
			</el-form-item>
			
			<el-form-item>
				<el-button type="primary" @click="save">保存</el-button>
			</el-form-item>
		</el-form>

	</div>
</template>

<script>
	export default {
		name: 'PersonnelInformationEdit',
		components: {
			
		},
		props: [
			'show',
			'editid'
		],
		data() {
			return {
				form: {
					id: '',
					name: '',
					gender: '',
					age: '',
					type: '',
					idNum: '',
					jobTitle: '',
					position: '',
					introduction: '',
					telephone: ''
				},
				depts:[],
				registLevels:[]
				// depts:[
				// 	{id:1,name:'肾内科'},
				// 	{id:2,name:'消化内科'}
				// ],
				// registLevls:[
				// 	{id:1,name:'专家'},
				// 	{id:2,name:'教授'}
				// ]
			}
		},
		created() {
			if (this.editid){
				this.show = true;
				this.$axios.get(
					'doctorInformation/update',
					response=> {
						this.form.id = this.editid;
						this.form.name = response.obj.name;
						this.form.gender = response.obj.gender;
						this.form.age = response.obj.age;
						this.form.type = response.obj.type;
						this.form.idNum = response.obj.idNum;
						this.form.jobTitle = response.obj.jobTitle;
						this.form.position = response.obj.position;
						this.form.introduction = response.obj.introduction;
						this.form.telephone = response.obj.telephone;
					},{
						id: this.editid
					}
				)
			}
		},
		getNowFormatDate() {
		    var date = new Date();
		    var seperator1 = "-";
		    var seperator2 = ":";
		    var month = date.getMonth() + 1;
		    var strDate = date.getDate();
		    if (month >= 1 && month <= 9) {
		        month = "0" + month;
		    }
		    if (strDate >= 0 && strDate <= 9) {
		        strDate = "0" + strDate;
		    }
		    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
		            + " " + date.getHours() + seperator2 + date.getMinutes()
		            + seperator2 + date.getSeconds();
		    return currentdate;
		},
		methods: {
			save() {
				this.axios.get('/doctorInformation/toAdd', (data) => {
					if (data) {
						this.$emit('update:show', false)
						this.$emit('getData')
					}

				}, this.form, '保存成功');
			},
		// 	loadData(){
		// 		//加载机构列表
		// 		this.axios.get('/dept?type=listAll', (data) => {
		// 			this.depts = data;
		// 		});
				
		// 		//加载机构列表
		// 		this.axios.get('/regist_level?type=queryList', (data) => {
		// 			this.registLevels = data;
		// 		});
		// 	}
			
			
			
		// },
		// created() {

		// 	if (this.userId) {
		// 		//当修改的时候 需要根据用户的 id， 将数据查询到页面
		// 		this.axios.get('/user?type=toEdit', (data) => {
		// 			this.form = data;
		// 		}, {
		// 			userId: this.userId
		// 		});
		// 	}
			
			//加载 科室、挂号级别信息
			// this.loadData();

		}
	}
</script>

<style>
</style>
